package lyq.zkhw;

import org.I0Itec.zkclient.ZkClient;

import java.util.ArrayList;
import java.util.List;

public class ZKHWClient2 {


    private final static String driver = "com.mysql.cj.jdbc.Driver" ;
    private  final static String url="jdbc:mysql://localhost:3306/my?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC";
    private  static String user;
    private  static String password;
    static ArrayList<String> infos = new ArrayList<String>();
    static ZkClient zkClient ;

    private void connetZK(){
        // 创建zkclient
        zkClient = new ZkClient("linux121:2181,linux122:2181,linux123:2181");

    }

    public static void main(String[] args) throws InterruptedException {
        ZKHWClient2 zkhwClient2 = new ZKHWClient2();
        zkhwClient2.connetZK();
        List<String> childrens = zkClient.getChildren("/mysqlConfs");
        String s = childrens.get(0);
//        String path = zkClient.createEphemeralSequential("/mysqlConfs/mysql",user+","+password+","+driver+","+url);
//        System.out.println("---->>> 服务器注册成功， user="+user+";password ="+password+";\n driver ="+driver+";url ="+url+";节点\n" +
//                "路路径信息=" +path);
        Object o = zkClient.readData("/mysqlConfs/"+s);
        System.out.println(o);
        zkClient.writeData("/mysqlConfs/"+s, "hive"+","+"root"+","+driver+","+url);
        Thread.sleep(Integer.MAX_VALUE);

    }
}
